<template>
  <div class="user-config">
    <!-- 头部 -->
    <div class="config-header">
      <div class="title"><h4>账号设置</h4></div>
      <div class="warning">
        <p>禁止发送色情、暴力、政治等敏感信息!违者封号!</p>
      </div>
      <div class="recharge-list">
        <div
          v-for="item in rechargeList"
          :key="item.id"
          class="recharge-item"
          :class="{ active: rechargeIndex == item.id }"
          @click="setRecharge(item)"
        >
          <img
            :src="rechargeIndex == item.id ? item.ingActiveUrl : item.imgUrl"
            alt=""
          />
          <p>{{ item.text }}</p>
        </div>
      </div>
    </div>
    <!-- 内容 -->
    <div class="config-content">
      <component :is="currentComp" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, shallowRef, markRaw } from "vue";
// 导入组件
import Overview from "./comp/overview/index.vue";
import Account from "./comp/account.vue";
import Payment from "./comp/payment.vue";

const OverviewRaw = markRaw(Overview);
const AccountRaw = markRaw(Account);
const PaymentRaw = markRaw(Payment);
// 当前组件
const currentComp = shallowRef(Overview);

// 导入图片
import accountImg from "@img/recharge/account.png";
import accountActiveImg from "@img/recharge/account-active.png";
import overviewImg from "@img/recharge/overview.png";
import overviewActiveImg from "@img/recharge/overview-active.png";
import rechargeImg from "@img/recharge/recharge.png";
import rechargeActiveImg from "@img/recharge/recharge-active.png";
const rechargeList = ref([
  {
    id: 1,
    text: "总览",
    imgUrl: accountImg,
    ingActiveUrl: accountActiveImg,
    comp: Overview,
  },
  {
    id: 2,
    text: "账户",
    imgUrl: overviewImg,
    ingActiveUrl: overviewActiveImg,
    comp: Account,
  },
  {
    id: 3,
    text: "充值",
    imgUrl: rechargeImg,
    ingActiveUrl: rechargeActiveImg,
    comp: Payment,
  },
]);

const rechargeIndex = ref(1);
// 切换组件
const setRecharge = (item) => {
  rechargeIndex.value = item.id;
  currentComp.value = item.comp;
};
</script>

<style lang="scss" scoped>
.user-config {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 28px 36px 23px 41px;
  display: flex;
  flex-direction: column;
  //   头部
  .config-header {
    .title {
      height: 21px;
      border-left: 3px solid #c90000;
      h4 {
        font-weight: 400;
        font-size: 19px;
        color: #232323;
        padding-left: 7px;
      }
    }
    .warning {
      margin-top: 13px;
      width: 100%;
      height: 28px;
      line-height: 28px;
      background: #fff7f7;
      border-radius: 5px 5px 5px 5px;
      border: 1px solid #c90000;
      padding-left: 10px;
      p {
        width: 100%;
        height: 14px;
        font-size: 11px;
        color: #c90000;
      }
    }
    .recharge-list {
      margin-top: 27px;
      display: flex;

      .recharge-item {
        display: flex;
        align-items: center;
        margin-right: 67px;
        cursor: pointer;
        padding-bottom: 7px;

        img {
          width: 9px;
          height: 9px;
        }
        p {
          font-weight: 400;
          font-size: 13px;
          color: #232323;
          margin: 0;
          margin-left: 7px;
        }
      }
      .active {
        border-bottom: 2px solid #c90000;
        p {
          color: #c90000;
        }
      }
    }
  }
  //   内容
  .config-content {
    flex: 1;
    background: #ffffff;
    border-radius: 7px 7px 7px 7px;
    margin-top: 13px;
    padding: 15px 35px;
    overflow: auto;
  }
}
</style>
